<%@ page import="dao.UserInfoDao" %>
<%@ page import="dao.impl.UserInfoDaoImpl" %>
<%@ page import="bean.UserLogin" %>
<%@ page import="java.util.List" %>

<%--
  Created by IntelliJ IDEA.
  User: srq
  Date: 2021/5/2
  Time: 12:20
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
<head>
    <title>登录页面</title>
    <script type="text/javascript" src="js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>

    <!--导入自己的JS文件或JS语句-->
    <link rel="stylesheet" href="css/bootstrap.css" />
    <link rel="stylesheet" href="css/bootstrap-theme.css"/>
    <!--导入自己的CSS文件或CSS语句-->
    <style>

        label{
            color: #3b97d1;
            height: 40px;
        }

        div{
            height: 40px;
        }
        span{
            color: #FFD700;
            height: 40px;
        }

    </style>
</head>
<body>



<form action="login" class="form-horizontal" method="post">
    <div class="form-group">
        <fieldset>
            <div>
            </div>
            <div>
            </div>


            <label class="col-sm-4 control-label">用户名:</label>
            <div class="col-sm-4">
                <label>
                    <input type="text" class="form-control" name="userName"  placeholder="请输入用户名"/>
                </label>
            </div>
            <div class="col-sm-4">
            </div>


            <label class="col-sm-4 control-label">密码:</label>
            <div class="col-sm-4" >
                <label>
                    <input type="password" class="form-control" name="passWord"  placeholder="请输入密码"/>
                </label>
            </div>
            <div class="col-sm-4">
            </div>


            <label class="col-sm-4 control-label"></label>
            <div class="col-sm-8">
                <input type="submit" class="btn btn-success" id="sub" value="登录"/>&nbsp;&nbsp;&nbsp;
                <input type="reset" class="btn btn-primary" value="重置" >
            </div>


        </fieldset>
    </div>



</form>



<%

    request.setCharacterEncoding("UTF-8");

    UserInfoDao dao = new UserInfoDaoImpl();
    UserLogin user = new UserLogin();
    List<UserLogin> userLogins = dao.allInfo();

    String userName = request.getParameter("userName");
    String passWord = request.getParameter("passWord");

    user.setUserName(userName);
    user.setPassWord(passWord);

    if (userLogins.contains(user)){
        System.out.println("用户登录成功~");
        session.setAttribute("userName",userName);
        session.setAttribute("passWord",passWord);
        response.sendRedirect("success.jsp");
    }
%>

</body>
</html>


